<template>
<div>
    <common-header
        :title="title"
        :type=3></common-header>
    <div class="mui-content">
        <div class="swipe-div">
            <mt-swipe :auto="0">
                <mt-swipe-item class="slide1" v-for="(img, index) in imgList" :key="index"><a href="javascript: void(0)"><img :src="img" preview="0" /></a></mt-swipe-item>
            </mt-swipe>
        </div>
        <div class="audit-tui">
            <a class="mui-action-back mui-icon iconfont icon-tuijian1"></a>
        </div>
        <div class="audit-details">
            <ul>
                <li>
                    <p class="audit-details-title">样衣编号:</p>
                    <p class="audit-details-conts">{{ data.sampleId }}</p>
                </li>
                <li>
                    <p class="audit-details-title">大类:</p>
                    <p class="audit-details-conts">{{ data.dlText }}</p>
                </li>
                <li>
                    <p class="audit-details-title">货号:</p>
                    <p class="audit-details-conts">{{ data.pcode }}</p>
                </li>
                <li>
                    <p class="audit-details-title">小类:</p>
                    <p class="audit-details-conts">{{ data.xlText }}</p>
                </li>
                <li>
                    <p class="audit-details-title">颜色:</p>
                    <p class="audit-details-conts">{{ data.sampleId }}</p>
                </li>
                <li>
                    <p class="audit-details-title">尺寸:</p>
                    <p class="audit-details-conts">{{ data.sampleId }}</p>
                </li>
                <li>
                    <p class="audit-details-title">报价:</p>
                    <p class="audit-details-conts">{{ data.sampleId }}</p>
                </li>
                <li>
                    <p class="audit-details-title">样衣数量:</p>
                    <p class="audit-details-conts">{{ data.sampleId }}件</p>
                </li>
                <li>
                    <p class="audit-details-title">波段号:</p>
                    <p class="audit-details-conts">{{ data.bandid }}</p>
                </li>
                <li>
                    <p class="audit-details-title">合作方式:</p>
                    <p class="audit-details-conts">{{ data.sampleId }}</p>
                </li>
                <li>
                    <p class="audit-details-title">供货商:</p>
                    <p class="audit-details-conts">{{ data.vendername }}</p>
                </li>
            </ul>
        </div>
        <div class="sDemand-details-upload-sure sDemand-details-sure primaryList-details-sure">
            <button id="primaryList-details-sure" type="button" class="mui-btn mui-btn-blue" @click="confirm">确认收货</button>
        </div>
    </div>
</div>
</template>
<script>
import { mapState, mapMutations } from 'vuex'
import commonHeader from '@/components/commonHeader.vue'
import { Swipe, SwipeItem } from 'mint-ui';
import API from '@/service/api'
export default {
    components: { commonHeader, Swipe, SwipeItem },
    data() {
        return {
            title: '淘汰样衣详情',
            imgList: [],
            data: {},
        }
    },
    computed: {
        ...mapState( [ 'sample_id', 'sample_no' ] ) 
    },      
    methods: {
        ...mapMutations( [ 'UPDATE_SHOW_LOADING' ] ),
        async initialization() {
            //获取基本信息
            this.data = await API.currency.getSampleDetail({ ID: this.sample_no })
            //获取样衣图片列表
            let imgs = await API.currency.getSampleImgs({ sampleId: this.sample_id })
            for(let i = 1; i<6; i++) {
                const img = imgs[`limg${i}`]
                if(img)
                    this.imgList.push(img)
            }
            this.$previewRefresh()
            this.UPDATE_SHOW_LOADING(false)
        },
        confirm() {
            this.UPDATE_SHOW_LOADING(true)
            API.eliminate.takeOneSample({ sampleId: this.sample_id, ids: [] }).then( res => {
                this.UPDATE_SHOW_LOADING(false)
                if(res.code == 1) {
                    this.$success()
                    setTimeout(()=>{
                        this.$router.push( { name: 'eliminate' } )
                    },1000)
                }else this.$error(res.errMsg)  
            })
        }
    },
    created() {
       this.initialization()
    } 
}
</script>
<style scoped>
</style>